<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="dgg" uri="/dgg-tags" %>
<!DOCTYPE html>
<!--新增入库弹窗 start-->
<div class="content-layerbody-main" id="add">
    <form name="credentialForm" id="credentialForm">
        <div class="finan-panel">
            <div class="finan-tit">
                <b>证书信息</b>
            </div>
            <div class="panel-table">
                <table class="layui-table table-info">
                    <tbody>
                    <tr>
                        <th><span class="required">证书类型</span></th>
                        <td>
                            <select class="table-select" name="certificateType" id="certificateTypes" onchange="loadCertificateType('100%','#certificateTypes','${generalType}',1,'#certificateSpecialty',0,'#certificateLevels')">
                                <option value=''>请选择</option>
                            </select>
                        </td>
                        <th><span class="required">证书专业</span></th>
                        <td>
                            <select class="table-select" name="certificateSpecialtys" multiple="multiple" id="certificateSpecialty" onchange="checkCertificateSpecialty('#certificateTypes','#certificateSpecialty')">
                                <option value="">请先选择证书类型</option>
                            </select>
                        </td>
                        <th><span class="required">证书级别</span></th>
                        <td>
                            <select class="table-select" name="certificateLevel" id="certificateLevels">
                                <option value="">请先选择证书类型</option>
                            </select>
                        </td>
                        <th><span class="required">地区</span></th>
                        <td>
                            <div class="bus-plugIn" id="certificateAreas">
                                <input type="hidden" name="certificateAreaId" class="plug-in-msg"/>
                                <input type="hidden" name="certificateArea" class="plug-in-code" value="${empty credential.certificateArea ? credential.areaProvince :credential.certificateArea}"/>
                                <input type="text" readonly placeholder="请选择" class="chose-plugIn layui-input" name="areaName" id="certificateName" value="<dgg:tbcode code='${credential.areaProvince}'/> <c:if test="${!empty credential.certificateArea}">/<dgg:tbcode code='${credential.certificateArea}'/></c:if>"/>
                                <div class=" bus-picker">
                                    <div class="bus-picker-tab">
                                        <a href="javascript:void(0);" class="active">请选择</a>
                                    </div>
                                    <div class="bus-picker-content"></div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th><span class="required">证书编号</span></th>
                        <td>
                            <input type="text" class="table-input" name="certificateNo" id="certificateNo" maxlength="200" onblur="checkCertificateNo(this,'GENERAL_CREDENTIAL','${credential.id}')" value="${credential.certificateNo}" onblur="checkCertificateNo(this,'GENERAL_CREDENTIAL','${ceretificateId}',0)">
                        </td>
                        <th><span class="required">适用范围</span></th>
                        <td>
                            <select class="table-select" name="applicationScope">
                                <c:forEach var="p" items="${applicationScopes}">
                                    <option value="${p.code}">${p.name}</option>
                                </c:forEach>
                            </select>
                        </td>
                        <th>证书过期时间</th>
                        <td>
                            <input type="text" class="table-input Wdate" name="certificateExpiryTimes" autocomplete="off" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'%y-%M-%d'})"/>
                        </td>
                        <th><span class="required">合同签订时间</span></th>
                        <td>
                            <input type="text" class="table-input Wdate" name="contractSigningTimes" id="contractSigningTimes" autocomplete="off" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>
                        </td>

                    </tr>
                    <tr>
                        <th>三类证书</th>
                        <td>
                            <select class="table-select" name="certificateToThree">
                                <option value="">请选择</option>
                                <c:forEach var="p" items="${certificateToThrees}">
                                    <option value="${p.code}" <c:if test="${credential.certificateToThree eq p.code}">selected</c:if>>${p.name}</option>
                                </c:forEach>
                            </select>
                        </td>
                        <th>三类证书到期时间</th>
                        <td>
                            <input type="text" class="table-input Wdate" name="certificateToThreeTimes" autocomplete="off" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'%y-%M-%d'})"/>
                        </td>
                        <th><span class="required">回收价格</span></th>
                        <td>
                            <label class="input-unit">
                                <input type="text" class="table-input" name="receiptPrice" id="receiptPrices"  maxlength="200" value="${empty credential.receiptPrice ? 0:credential.receiptPrice}">
                                <span class="unit">元</span>
                            </label>
                        </td>
                        <th>证书总价</th>
                        <td>
                            <label class="input-unit">
                                <input type="text" class="table-input" placeholder="挂出价格" name="certificatePrice" disabled maxlength="200" value="${empty credential.certificatePrice ? '-':credential.certificatePrice}">
                                <span class="unit">元</span>
                            </label>
                        </td>
                    </tr>
                    <tr>
                        <th>类别</th>
                        <td>
                            <select class="table-select" name="certificateCategory">
                                <option value="">请选择</option>
                                <c:forEach var="p" items="${certificateCategorys}">
                                    <option value="${p.code}" <c:if test="${credential.certificateCategory eq p.code}">selected</c:if>>${p.name}</option>
                                </c:forEach>
                            </select>
                        </td>
                        <th><span class="required">证书名称</span></th>
                        <td>
                            <input type="text" class="table-input" name="certificateName" id="certificateNames" maxlength="200" value="${credential.certificateName}">
                        </td>
                        <th><span class="required">是否买社保</span></th>
                        <td>
                            <select class="table-select" id="socialSecurity" name="socialSecurity" onchange="showSocialSecurityArea()">
                                <option value="">请选择</option>
                                <c:forEach var="p" items="${socialSecurity}">
                                    <option value="${p.code}" <c:if test="${credential.socialSecurity eq p.code}">selected</c:if>>${p.name}</option>
                                </c:forEach>
                            </select>
                        </td>
                        <th><span name="isSocialSecurity" style="display: none;color:red;">*</span>社保区域</th>
                        <td>
                            <div id="divSocialSecurityArea" class="layui-input-inline" style="display: none">
                                <div class="bus-plugIn" id="socialSecurityArea">
                                    <input type="hidden" name="socialSecurityAreaId" class="plug-in-msg"/>
                                    <input type="hidden" name="socialSecurityArea" class="plug-in-code" value="${empty credential.socialSecurityAreaId ? credential.socialSecurityArea :credential.socialSecurityAreaId}"/>
                                    <input type="text" readonly placeholder="请选择" class="chose-plugIn layui-input" id="socialSecurityAreaChange" name="socialSecurityAreaChange" value="<dgg:tbcode code='${credential.socialSecurityArea}'/> <c:if test="${!empty credential.socialSecurityAreaId}">/<dgg:tbcode code='${credential.socialSecurityAreaId}'/></c:if>">
                                    <div class="bus-picker">
                                        <div class="bus-picker-tab">
                                            <a href="javascript:void(0);" class="active">请选择</a>
                                        </div>
                                        <div class="bus-picker-content"></div>
                                    </div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th><span class="required">人才原件是否配合</span></th>
                        <td>
                            <select class="table-select" name="isTalentOriginalCopyCoordinate">
                                <option value="0" <c:if test="${credential.isTalentOriginalCopyCoordinate eq '0'}">selected</c:if>>是</option>
                                <option value="1" <c:if test="${credential.isTalentOriginalCopyCoordinate eq '1'}">selected</c:if>>否</option>
                            </select>
                        </td>
                        <th><span class="required">人才出场是否配合</span></th>
                        <td>
                            <select class="table-select" name="isTalentAppearanceCoordinate">
                                <option value="0" <c:if test="${credential.isTalentAppearanceCoordinate eq '0'}">selected</c:if>>是</option>
                                <option value="1" <c:if test="${credential.isTalentAppearanceCoordinate eq '1'}">selected</c:if>>否</option>
                            </select>
                        </td>
                        <th>特殊备注</th>
                        <td>
                            <input type="text" class="table-input" name="specialNote" id="specialNote" maxlength="30">
                        </td>

                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="finan-panel">
            <div class="finan-tit">
                <b>收证信息</b>
            </div>
            <div class="panel-table">
                <table class="layui-table table-info">
                    <tbody>
                    <tr>
                        <th>收证商务</th>
                        <td>
                            <input type="text" class="table-input" name="collectorName" value="${products.signUserName}" readonly>
                            <input type="hidden" class="table-input" name="collectorId" value="${products.signUserId}">
                        </td>
                        <th>合同编号</th>
                        <td>
                            <input type="text" class="table-input" name="contractNo" value="${products.contractNo}" readonly>
                        </td>
                        <th><span class="required">是否代签</span></th>
                        <td>
                            <select class="table-select" name="isWhetherSign">
                                <option value="0" <c:if test="${credential.isWhetherSign eq '0'}">selected</c:if>>是</option>
                                <option value="1" <c:if test="${credential.isWhetherSign eq '1'}">selected</c:if>>否</option>
                            </select>
                        </td>
                        <th>证书录入时间</th>
                        <td>
                            <!-- 新增证书默认录入时间为当前时间 -->
                            <input type="text" class="table-input" name="certificateEntryTimes" value="${date}" autocomplete="off" readonly>
                        </td>
                    </tr>
                    <tr>
                        <th><span class="red">*</span>持证人姓名</th>
                        <td>
                            <input type="text" class="table-input" name="personalName" id="personalNames" maxlength="200" value="${credential.personalName}">
                        </td>
                        <th>身份证号码</th>
                        <td>
                            <input type="text" class="table-input" name="personalIdCard" id="personalIdCards" maxlength="200" value="${credential.personalIdCard}">
                        </td>
                        <th><span class="red">*</span>联系电话</th>
                        <td>
                            <input type="text" class="table-input" name="personalPhone" id="personalPhones" maxlength="200" value="${credential.personalPhone}">
                        </td>
                        <th>微信号码</th>
                        <td>
                            <input type="text" class="table-input" name="personalWeixin" id="personalWeixins" maxlength="200" value="${credential.personalWeixin}">
                        </td>
                    </tr>
                    <tr>
                        <th><span class="red">*</span>收款户名</th>
                        <td>
                            <input type="text" class="table-input" name="accountName" id="accountNames" maxlength="200" value="${credential.accountName}">
                        </td>
                        <th><span class="red">*</span>收款账号</th>
                        <td>
                            <input type="text" class="table-input" name="accountNo" id="accountNos" maxlength="200" value="${credential.accountNo}">
                        </td>
                        <th><span class="red">*</span>开户行</th>
                        <td>
                            <input type="text" class="table-input" name="accountBank" id="accountBanks" maxlength="200" value="${credential.accountBank}">
                        </td>
                        <th>定金（元）</th>
                        <td>
                            <label class="input-unit">
                                <input type="text" class="table-input" name="deposit" value="${products.theDeposit}" readonly maxlength="200">
                                <span class="unit">元</span>
                            </label>
                        </td>
                    </tr>

                    <tr>
                        <th><span class="required">人才付款方式</span></th>
                        <td>
                            <select class="table-select" name="talentPaymentMethod" id="talentPaymentMethod">
                                <option value="0" <c:if test="${credential.talentPaymentMethod eq '0'}">selected</c:if>>签付</option>
                                <option value="1" <c:if test="${credential.talentPaymentMethod eq '1'}">selected</c:if>>使用后付款</option>
                            </select>
                        </td>
                        <th><span class="required">收证类型</span></th>
                        <td>
                            <select class="select-style" name="receiptType" onchange="receiptType1()">
                                <option value="0" <c:if test="${credential.receiptType eq '0'}">selected</c:if>>渠道收证</option>
                                <option value="1" <c:if test="${credential.receiptType eq '1'}">selected</c:if>>人才收证</option>
                            </select>
                        </td>
                        <th><span name="receiptType" style="display: none;color:red;">*</span>渠道名称</th>
                        <td >
                            <input type="text" class="table-input" name="channelName" id="channelName" value="${credential.channelName}">
                        </td>
                        <th><span name="receiptType" style="display: none;color:red;">*</span>渠道电话</th>
                        <td >
                            <input onkeyup="this.value=this.value.replace(/\D/g,'')" type="text" class="table-input" name="channelPhone" id="channelPhone" maxlength="11" value="${credential.channelPhone}">
                        </td>
                    </tr>

                    <tr>
                        <th><span name="receiptType" style="display: none;color:red;">*</span>渠道身份证号</th>
                        <td>
                            <input type="text" class="table-input" name="channelIdCard" id="channelIdCard" value="${credential.channelIdCard}">
                        </td>
                        <th>定金支付时间</th>
                        <td>
                            <input type="text" class="table-input" name="depositPayTimes" autocomplete="off" value="<fmt:formatDate value="${products.theDepositTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" readonly>
                        </td>
                        <th>尾款</th>
                        <td>
                            <label class="input-unit">
                                <input type="text" class="table-input" name="tailMoney" value="${products.balancePayment}" readonly>
                                <span class="unit">元</span>
                            </label>
                        </td>
                        <th>尾款支付时间</th>
                        <td>
                            <input type="text" class="table-input" name="tailMoneyPayTimes" autocomplete="off" value="<fmt:formatDate value="${products.balancePaymentTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" readonly>
                        </td>
                    </tr>
                    <tr>
                        <th><span class="red">*</span>是否有资格证书</th>
                        <td>
                            <select class="table-select" name="isQuelificationCertificate">
                                <option value="0" <c:if test="${credential.isQuelificationCertificate eq '0'}">selected</c:if>>是</option>
                                <option value="1" <c:if test="${credential.isQuelificationCertificate eq '1'}">selected</c:if>>否</option>
                            </select>
                        </td>
                        <th><span class="red">*</span>是否有毕业证书</th>
                        <td>
                            <select class="table-select" name="isGraduationCertificate">
                                <option value="0" <c:if test="${credential.isGraduationCertificate eq '0'}">selected</c:if>>是</option>
                                <option value="1" <c:if test="${credential.isGraduationCertificate eq '1'}">selected</c:if>>否</option>
                            </select>
                        </td>
                        <%--<th><span class="red">*</span>是否有信息卡</th>--%>
                        <%--<td>--%>
                            <%--<select class="table-select" name="isInformationCard">--%>
                                <%--<option value="0" <c:if test="${credential.isInformationCard eq '0'}">selected</c:if>>是</option>--%>
                                <%--<option value="1" <c:if test="${credential.isInformationCard eq '1'}">selected</c:if>>否</option>--%>
                            <%--</select>--%>
                        <%--</td>--%>
                        <th><span class="red">*</span>是否集团归档</th>
                        <td>
                            <select class="table-select" name="isGroupFiling">
                                <option value="0" <c:if test="${credential.isGroupFiling eq '0'}">selected</c:if>>是</option>
                                <option value="1" <c:if test="${credential.isGroupFiling eq '1'}">selected</c:if>>否</option>
                            </select>
                        </td>
                        <th></th>
                        <td>
                            <!-- 基础证书id -->
                            <input type="hidden" name="id" id="id" value="${credential.id}">
                            <input type="hidden" name="generalCertificateId" id="generalCertificateId" value="${credential.generalCertificateId}">
                            <!-- 生产订单id -->
                            <input type="hidden" name="scOrderId" id="scOrderId" value="${products.scProductOrderId}">
                            <input type="hidden" name="scOrderNo" id="scOrderNo" value="${products.scProductOrderNo}">
                            <!-- 销售子订单id -->
                            <input type="hidden" name="productId" id="productId" value="${products.id}">
                            <!-- 签单事业部 -->
                            <input type="hidden" name="signOrgId" id="signOrgId" value="${products.productOrgId}">
                            <input type="hidden" name="signOrgName" id="signOrgName" value="${products.productOrgName}">
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="finan-panel">
            <div class="finan-tit">
                <b>证书状态</b>
            </div>
            <div class="panel-table">
                <table class="layui-table table-info">
                    <tbody>
                    <tr>
                        <th>证书状态</th>
                        <td>
                            <!-- 新增证书默认在库状态为出库 -->
                            <input type="text" class="table-input" value="未使用" disabled>
                            <input type="hidden" name="certificateStatus" value="GENERAL_CREDENTIAL_STATUS_01">
                        </td>
                        <th>在库状态</th>
                        <td>
                            <!-- 新增证书默认出入库状态为在库 -->
                            <input type="text" class="table-input" value="在库" disabled>
                            <input type="hidden" name="libraryStatus" value="GENERAL_CERTIFICATE_LIBRARY_STATUS_01">
                        </td>
                        <th>最新入库时间</th>
                        <td>
                            <input type="text" class="table-input" name="lastWarehousingTimes" autocomplete="off" placeholder="最新入库时间" value="${date}">
                        </td>
                        <th>最新出库时间</th>
                        <td>
                            <!-- 新增证书默认入库时间为当前时间 -->
                            <input type="text" class="table-input" name="lastOutgoingTimes" placeholder="最新出库时间" readonly>
                        </td>
                    </tr>
                    <tr>
                        <th>人才合同到期时间</th>
                        <td>
                            <input type="text" class="table-input Wdate" name="talentContractExpireTimes" autocomplete="off" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'%y-%M-%d'})">
                        </td>
                        <th>企业合同到期时间</th>
                        <td>
                            <input type="text" class="table-input Wdate" name="companyContractExpireTimes" autocomplete="off" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'%y-%M-%d'})">
                        </td>
                        <th>使用公司</th>
                        <td>
                            <input type="text" class="table-input" name="affiliatedCompany" disabled maxlength="200" placeholder="使用公司">
                        </td>
                        <th>使用起始时间</th>
                        <td>
                            <input type="text" class="table-input" name="affiliatedStartTimes" autocomplete="off" placeholder="使用起始时间" readonly>
                        </td>
                    </tr>
                    <tr>
                        <th>使用到期时间</th>
                        <td>
                            <input type="text" class="table-input" name="affiliatedExpireTimes" autocomplete="off" placeholder="使用到期时间" readonly>
                        </td>
                        <th>三类使用公司</th>
                        <td>
                            <input type="text" class="table-input" name="threeAffiliatedCompany" placeholder="三类使用公司" maxlength="200" readonly>
                        </td>
                        <th>三类使用起始时间</th>
                        <td>
                            <input type="text" class="table-input" name="threeAffiliatedStartTimes" autocomplete="off" placeholder="三类使用起始时间" readonly>
                        </td>
                        <th>三类使用到期时间</th>
                        <td>
                            <input type="text" class="table-input" name="threeAffiliatedExpireTimes" autocomplete="off" placeholder="三类使用到期时间" readonly>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="finan-panel">
            <div class="finan-tit">
                <b>附件信息</b>
            </div>
            <div class="panel-main">
                <ul class="data-warp">
                    <li style="width: 100px;">证书附件</li>
                    <li>
                        <a href="javascript:void(0)" class="upload-button" id="upload"></a>
                        <input class="layui-upload-file" type="file" name="file" multiple="" id="annexUpload" data-type="credential" data-fileid="${credential.id}" is-remove="1" load-file="1">
                        <p>上传附件</p>
                    </li>
                </ul>
                <ul class="data-warp">
                    <li style="width: 100px;">证书使用附件</li>
                    <li>
                        <a href="javascript:void(0)" class="upload-button" id="upload1"></a>
                        <input class="layui-upload-file" type="file" name="file" multiple="" id="annexUpload1" data-type="attachmentForCertificate" data-fileid="${credential.id}" is-remove="1" load-file="1">
                        <p>上传附件</p>
                    </li>
                </ul>
                <ul class="data-warp">
                    <li style="width: 100px;">财务付款附件</li>
                    <li>
                        <a href="javascript:void(0)" class="upload-button" id="upload2"></a>
                        <input class="layui-upload-file" type="file" name="file" multiple="" id="annexUpload2" data-type="financialPaymentAttachment" data-fileid="${credential.id}" is-remove="1" load-file="1">
                        <p>上传附件</p>
                    </li>
                </ul>
            </div>
        </div>
    </form>
</div>
<script src="${rootUrl}/static/js/zzsc/common/files/annex.js?v=${version}" type="text/javascript" charset="utf-8"></script>


<!--新增入库弹窗 end-->
<script>
    $(function () {
        loadCertificateVal('#certificateTypes', '${credential.certificateType}', '${generalType}', 0, 0, "#certificateLevels", '${credential.certificateLevel}');
        loadCertificateVal('#certificateSpecialty', '${credential.certificateSpecialtys}', '${generalType}', '${credential.certificateType}', 1);
        //异步加载
        Plug.plug_ins(
            "get",
            "${cmsBaseUrl}/api/cms/tree_book/v1/get_tree_book_list.do?code=2147483647&type=2&level=1",
            "#certificateAreas",
            '请选择地区',
            function () {
            },
            true, '2147483647'
        );
        Plug.plug_ins(
            "get",
            "${cmsBaseUrl}/api/cms/tree_book/v1/get_tree_book_list.do?code=2147483647&type=2&level=1",
            "#socialSecurityArea",
            '请选择地区',
            function () {
            },
            true, '2147483647'
        );
        showSocialSecurityArea()
        receiptType1()

    });

    /**
     * 显示社保区域
     */
    function showSocialSecurityArea() {

        let socialSecurity = $('#socialSecurity').val();
        if (socialSecurity === '0'){
            $("#divSocialSecurityArea").css("display","block")
            $("span[name=isSocialSecurity]").css("display","inline-block")
        } else {
            $("#divSocialSecurityArea").css("display","none")
            $("span[name=isSocialSecurity]").css("display","none")
            $("input[name=socialSecurityAreaId]").val("")
            $("input[name=socialSecurityArea]").val("")
            $("input[name=socialSecurityAreaChange]").val("")
        }
    }
    /**
     * 显示渠道信息
     */
    function receiptType1() {

        let receiptType = $('select[name=receiptType]').val();
        if (receiptType == 0 && receiptType != ''){
            $("span[name=receiptType]").css("display","inline-block")
            document.getElementById("channelName").readOnly=false;
            document.getElementById("channelPhone").readOnly=false;
            document.getElementById("channelIdCard").readOnly=false;
        } else {
            $("#channelName").val("");
            $("#channelPhone").val("");
            $("#channelIdCard").val("");
            $("span[name=receiptType]").css("display","none")
            document.getElementById("channelName").readOnly=true;
            document.getElementById("channelPhone").readOnly=true;
            document.getElementById("channelIdCard").readOnly=true;
        }
    }
</script>